package someClass;

// 内部类
class OuterClass {
    private String outerField = "Outer";

    class InnerClass {
        void display() {
            System.out.println("Outer field is: " + outerField);
        }
    }
}

//静态成员
class numAdd {
    public static int add(int a, int b) {
        return a + b;
    }
}


//构造方法
class touyota{
    String color;
    int year;

    //构造方法
    public void detail(String color, int year){
        this.color = color;
        this.year = year;
    }
}

public class Object {


    public static void main(String[] args) {
        // 类和对象 的实际运用
        Car myCar = new Car();
        myCar.color = "red";
        myCar.year = 2020;
        myCar.drive();

        System.out.println(myCar.color);
        System.out.println(myCar.year);
        System.out.println("*****************");

        Dog myDog = new Dog();
        myDog.eat(); // 继承自 Animal类
        myDog.bark();

        System.out.println("******************");

        MathUtils math = new MathUtils();
        int num1 = math.add(1,2);
        double num2 = math.add(2.3,32.1);

        System.out.println(num1);
        System.out.println(num2);

        System.out.println("******************");

        Animal myDog1 = new Dog();
        myDog1.makeSound(); // 输出 "Bark"

        Dog myDog2 = new Dog();
        myDog2.makeSound(); //

        Animal ani = new Animal();
        ani.makeSound();

        // 这个行不通
        //Dog ani1 = new Animal();
        //ani1.makeSound();

        System.out.println("******************");

        Male man = new Man();
        man.makeSound();

        System.out.println("******************");

        EnglishBook english = new EnglishBook();
        english.makeSound();

        System.out.println("******************");

        touyota car1 = new touyota();
        car1.detail("blue",23);

        System.out.println(car1.color);
        System.out.println(car1.year);
        //System.out.println("this is year"car1.year);

        System.out.println("******************");

        int result = numAdd.add(5, 3); // 不需要实例化 MathUtils 类
        System.out.println(result); // -------> 8

        System.out.println("******************");

        OuterClass outer = new OuterClass();
        OuterClass.InnerClass inner = outer.new InnerClass();
        inner.display();

        System.out.println("******************");


    }
}
